package com.touwowo.eight;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.touwowo.utils.RabbitMqUtils;

import java.nio.charset.StandardCharsets;

public class Producer {
    private static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        //设置过期时间
        AMQP.BasicProperties properties =
                new AMQP.BasicProperties()
                        .builder().expiration("10000").build();
        for (int i = 0; i < 10; i++) {
            String message = new String("Producer" + i);
            channel.basicPublish(NORMAL_EXCHANGE, "normal", null, message.getBytes(StandardCharsets.UTF_8));
            System.out.println("生产者发出消息：" + message);
        }
    }
}
